#set working directory
setwd()

#load packages
library(tidyverse)
library(haven)
library(ggplot2)
library(patchwork)
library(margins)
library(sjPlot)
library(stargazer)
library(texreg)

#load and prepare data
data_eu <- read_csv("CONSOLI_JEPP.csv")

data_eu <- data_eu %>% mutate(tgroup = case_when(rec_treatment_ex3 == 1 ~ "T1",
                                                 rec_treatment_ex3 == 2 ~ "T2",
                                                 rec_treatment_ex3 == 3 ~ "T3",
                                                 rec_treatment_ex3 == 4 ~ "Control"))
data_eu$tgroup <- as.factor(data_eu$tgroup)

## create country data frames
DE <- data_eu %>% filter(country == "DE")
IT <- data_eu %>% filter(country == "IT")
PL <- data_eu %>% filter(country == "PL")
SWE <- data_eu %>% filter(country == "SWE")


#Descriptive results

##Figure 1: Citizens’ attitudes towards the sanctioning of norm-violating EU member states
OV3_prop_pool2 <- data_eu %>%
  ggplot(mapping = aes(x = OV3)) +
  geom_bar(mapping = aes(y = ..prop..)) +
  scale_y_continuous(limits = c(0, 0.5)) +
  labs(x = "Support", y = "Proportion", title = "EU should take measures to protect democracy")
OV3_facet_country_pool2 <- OV3_prop_pool2 + facet_wrap(vars(data_eu$country), ncol = 4)

cohesion_prop_pool2 <- data_eu %>%
  ggplot(mapping = aes(x = Exclusion_1)) +
  geom_bar(mapping = aes(y = ..prop..)) +
  scale_y_continuous(limits = c(0, 0.5)) +
  labs(x = "Support", y = "Proportion", title = "Exclude norm violators from cohesion funds")
cohesion_facet_ms <- cohesion_prop_pool2 + facet_wrap(vars(data_eu$country), ncol = 4)

transition_fund_exclusion_pool2 <- data_eu %>%
  ggplot(mapping = aes(x = Exclusion_2_2)) +
  geom_bar(mapping = aes(y = ..prop..)) +
  scale_y_continuous(limits = c(0, 0.5)) +
  labs(x = "Support", y = "Proportion", title = "Exclude norm violators from green subsidies")
transition_exclusion_facet_ms <- transition_fund_exclusion_pool2 + facet_wrap(vars(data_eu$country), ncol =4)

OV3_facet_country_pool2 + cohesion_facet_ms + transition_exclusion_facet_ms +
  plot_layout(ncol=1) +
  plot_annotation(tag_levels = "A")
ggsave("Figure1.jpeg", dpi=600)


##Figure 2: Support in Poland per partisan camp (vote choice)
PL <- PL %>% mutate(vote_choice = case_when(Q48_Polish == 1 ~ "Law & Justice",
                                            Q48_Polish == 2 ~ "Civic Platform",
                                            Q48_Polish == 3 ~ "Third Way",
                                            Q48_Polish == 4 ~ "New Left",
                                            Q48_Polish == 5 ~ "Confederation",
                                            Q48_Polish > 5  ~ "other/didn't vote"))
PL$vote_choice <- factor(PL$vote_choice, levels=c("Law & Justice","Civic Platform","Third Way","New Left","Confederation","other/didn't vote"))

PL_OV3_prop <- PL %>%
  ggplot(mapping = aes(x = OV3)) +
  geom_bar(mapping = aes(y = ..prop..)) +
  scale_y_continuous(limits = c(0, 0.6)) +
  labs(x = "Support", y = "Proportion")
PL_OV3_facet_party <- PL_OV3_prop + facet_wrap((vars(PL$vote_choice)))
PL_OV3_facet_party 
ggsave("Figure2.jpeg", dpi=600)


#Observational results

OV3_m_full_2 <- lm(OV3 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                     edu + income + age + sex + tgroup, data = data_eu)
cohe_m_full_2 <- lm(Exclusion_1 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                      edu + income + age + sex + tgroup, data = data_eu)
excl2_m_full_2 <- lm(Exclusion_2_2 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                       edu + income + age + sex + tgroup, data = data_eu)

##Figure 3: Individual-level determinants for support for EU measures against democratic backsliding.
all.models_2 <- list()
all.models_2[[1]] <- OV3_m_full_2
all.models_2[[2]] <- cohe_m_full_2
all.models_2[[3]] <- excl2_m_full_2

exlusion_models_2 <- plot_models(all.models_2,
                                 std.est ="std",
                                 rm.terms = c("tgroupT1", "tgroupT2", "tgroupT3", "sexmale", "age", "income", "edumiddle", "edulow"),
                                 axis.title = "Support",
                                 axis.labels = c("Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                 "Authoritarian", "Strong reciprocity", 
                                                 "TAN-GAL", "Left-Right", "Neither European nor national identity", "Exclusive national identity", 
                                                 "Affectedness"),
                                 m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                 vline.color = "black",
                                 colors = "Set2")
exlusion_models_2 
ggsave("Figure3.jpeg", exlusion_models_2, dpi=600)


##Table 2/Table A5: Public support for the exclusion of norm-violating member states from green subsides
greensub_m_full_2b <- lm(Exclusion_2_1 ~ worry_climate + affectedness + nat_identity + leftright + GAL + strong_reciprocity + 
                           authoritarian + Q20 + Q18 + trust_nat + edu + income + age + sex + tgroup, data = data_eu)
excl2_m_full_2b    <- lm(Exclusion_2_2 ~ worry_climate + affectedness + nat_identity + leftright + GAL + strong_reciprocity + 
                           authoritarian + Q20 + Q18 + trust_nat + edu + income + age + sex + tgroup, data = data_eu)
excl2_int1_full <- lm(Exclusion_2_2 ~ worry_climate  + affectedness + nat_identity + leftright + GAL + strong_reciprocity + 
                        authoritarian + Q20 + Q18 + trust_nat + edu + income + age + sex + tgroup + OV3 * worry_climate, data = data_eu)
excl2_int3_full <- lm(Exclusion_2_2 ~ worry_climate  + affectedness + nat_identity + leftright + GAL + strong_reciprocity + 
                        authoritarian + Q20 + Q18 + trust_nat + edu + income + age + sex + tgroup + OV3 * Exclusion_2_1, data = data_eu)

stargazer(greensub_m_full_2b, excl2_m_full_2b, excl2_int1_full, excl2_int3_full,
          type = "html",
          out = "green_subsidies_int1.html", 
          title = "Public Attitudes towards Green Subsidies",
          dep.var.labels = c("Support for green subsidies", "Exclusion from green subsidies", "Exclusion from green subsidies"),
          covariate.labels = c("Climate change worry", "Affectedness", "Exclusive national identity", "Neither European nor national identity",
                               "Left-Right", "TAN-GAL", 
                               "Strong reciprocity", "Authoritarian","Judicial oversight", 
                               "Satisfaction with national democracy", "Political trust (national)", 
                               "Education: middle", "Education: high", "Income", "Age", "Male", 
                               "Treatment group: T1", "Treatment group: T2", "Treatment group: T3", 
                               "EU should take action", "EU should take action X Climate change worry", 
                               "Support for green subsidies", "EU should take action X Support for green subsidies"),
          model.numbers    = TRUE,
          star.cutoffs = c(0.05, 0.01, 0.001))


#Experimental results
m1 = lm(OV1 ~ tgroup, data = data_eu)    #OV1 = EU functioning
m2 = lm(OV2 ~ tgroup, data = data_eu)    #OV2 = Integration should go further
m3 = lm(OV3 ~ tgroup, data = data_eu)    #OV3 = EU should take actions to protect RoL
m4a = lm(OV4r1 ~ tgroup, data = data_eu) #OV4r1 = COM trust
m4b = lm(OV4r2 ~ tgroup, data = data_eu) #OV4r2 = EP trust
m5 = lm(OV5 ~ tgroup, data = data_eu)    #OV5 = police cooperation
m6 = lm(OV6 ~ tgroup, data = data_eu)    #OV6 = green investment fund

##Figure 4: Experimental treatment effects on regime and policy support (predicted values)

OV1_effect <- plot_model(m1, type ="pred", 
                         title = "Satisfaction with EU functioning", 
                         axis.title = c("Treatment group", "Support"))
OV2_effect <- plot_model(m2, type ="pred", 
                         title = "Unification should go further", 
                         axis.title = c("Treatment group", "Support"))
OV4r1_effect <- plot_model(m4a, type ="pred",
                           title = "Trust in European Commission", 
                           axis.title = c("Treatment group", "Support"))
OV4r2_effect <- plot_model(m4b, type ="pred",
                           title = "Trust in European Parliament", 
                           axis.title = c("Treatment group", "Support"))
OV5_effect <- plot_model(m5, type ="pred", 
                         title = "Support for Police & Judicial Cooperation", 
                         axis.title = c("Treatment group", "Support"))
OV6_effect <- plot_model(m6, type ="pred", 
                         title = "Support for Green Investment Fund", 
                         axis.title = c("Treatment group", "Support"))

pred_grid <- plot_grid(c(OV1_effect, OV2_effect, OV4r1_effect, OV4r2_effect, OV5_effect, OV6_effect))
ggsave("Figure4.jpeg", pred_grid, dpi = 600)


######
#Appendix
######

#A2: Citizens worried about their country being targeted by EU sanctions

##Figure A2. Respondents worried about EU sanctions against their country due to violations of democratic norms.
affectedness_prop_pool2 <- data_eu %>%
  ggplot(mapping = aes(x = affectedness)) +
  geom_bar(mapping = aes(y = ..prop..)) +
  scale_x_continuous(breaks = c(0, 1)) +
  scale_y_continuous(limits = c(0, 0.8)) +
  labs(x = "Country could be targeted", y = "Proportion")
affectedness_facet <- affectedness_prop_pool2 + facet_wrap(vars(data_eu$country))

affectedness_facet
ggsave("affectedness.png", dpi=600)


#A3: Public support for EU sanctions: Pooled analysis

##Table A3.1 Public support for EU measures against democratic backsliding.
stargazer(OV3_m_full_2, cohe_m_full_2, excl2_m_full_2,
          type = "html",
          out = "exclusion_comp_identity.html", 
          title = "Public Support for the Exclusion of Norm Violating Member States",
          dep.var.labels = c("EU should take measures", "Exclusion cohesion fund", "Exclusion green subsidies"),
          covariate.labels = c("Affectedness", "Exclusive national identity", "Neither European nor national identity",
                               "Left-Right", "TAN-GAL", "Strong reciprocity", "Authoritarian", "Judicial oversight", "Satisfaction with national democracy", "Political trust (national)", "Education: middle", "Education: high",
                               "Income", "Age", "Male", "Treatment group: T1", "Treatment group: T2", "Treatment group: T3"),
          model.numbers    = TRUE,
          star.cutoffs = c(0.05, 0.01, 0.001))


##Table A3.2 Public support for EU measures against democratic backsliding (EU membership variable)
OV3_m_full_1 <- lm(OV3 ~ affectedness + membership + leftright + GAL + strong_reciprocity + 
                     authoritarian + Q20 + Q18 + trust_nat + edu + income + age + sex + tgroup, data = data_eu)
cohe_m_full_1 <- lm(Exclusion_1 ~ affectedness + membership + leftright + GAL + strong_reciprocity + 
                      authoritarian + Q20 + Q18 + trust_nat + edu + income + age + sex + tgroup, data = data_eu)
excl2_m_full_1 <- lm(Exclusion_2_2 ~ affectedness + membership + leftright + GAL + strong_reciprocity + 
                       authoritarian + Q20 + Q18 + trust_nat + edu + income + age + sex + tgroup, data = data_eu)

stargazer(OV3_m_full_1, cohe_m_full_1, excl2_m_full_1,
          type = "html",
          out = "exclusion_comp_membership.html", 
          title = "Public Support for the Exclusion of Norm Violating Member States",
          dep.var.labels = c("EU should take measures", "Exclusion cohesion fund", "Exclusion green subsidies"),
          covariate.labels = c("Affectedness", "EU membership: good", "EU membership: neither good nor bad",
                               "Left-Right", "TAN-GAL", "Strong reciprocity", "Authoritarian", "Judicial oversight", "Satisfaction with national democracy", "Political trust (national)", "Education: middle", "Education: high",
                               "Income", "Age", "Male", "Treatment group: T1", "Treatment group: T2", "Treatment group: T3"),
          model.numbers    = TRUE,
          star.cutoffs = c(0.05, 0.01, 0.001))


##Figure A3 Public support for EU measures against democratic backsliding. Standardised coefficients.
all.models <- list()
all.models[[1]] <- OV3_m_full_1
all.models[[2]] <- cohe_m_full_1
all.models[[3]] <- excl2_m_full_1

exlusion_models_1 <- plot_models(all.models,
                                 std.est ="std",
                                 rm.terms = c("tgroupT1", "tgroupT2", "tgroupT3", "sexmale", "age", "income", "edumiddle", "edulow"),
                                 title = "EU measures against democratic backsliding", 
                                 axis.title = "Support",
                                 axis.labels = c("Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                 "Authoritarian", "Strong reciprocity", 
                                                 "TAN-GAL", "Left-Right", "EU membership: neither good nor bad", "EU membership: good", "Affectedness"),
                                 m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                 vline.color = "black",
                                 colors = "Set2")
exlusion_models_1


#A4: Public support for EU sanctions: Country results

##Germany
DE_OV3_m_full_1 <- lm(OV3 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                        edu + income + age + sex, data = DE)
DE_OV3_m_full_2 <- lm(OV3 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                        edu + income + age + sex, data = DE) 
DE_cohe_m_full_1 <- lm(Exclusion_1 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                         edu + income + age + sex, data = DE)
DE_cohe_m_full_2 <- lm(Exclusion_1 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                         edu + income + age + sex, data = DE) 
DE_excl2_m_full_1 <- lm(Exclusion_2_2 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                          edu + income + age + sex, data = DE)
DE_excl2_m_full_2 <- lm(Exclusion_2_2 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                          edu + income + age + sex, data = DE)

DE_exclusion_models_1 <- plot_models(DE_OV3_m_full_1, DE_cohe_m_full_1, DE_excl2_m_full_1,
                                     std.est ="std", 
                                     title = "Germany", 
                                     axis.title = "Support",
                                     axis.labels = c("Sex: male", "Age", "Income", "Education: high", "Education: middle", 
                                                     "Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                     "Authoritarian", "Strong reciprocity", 
                                                     "TAN-GAL", "Left-Right", "EU membership: neither good nor bad", "EU membership: good", "Affectedness"),
                                     m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                     vline.color = "black",
                                     colors = "Set2")

DE_exclusion_models_2 <- plot_models(DE_OV3_m_full_2, DE_cohe_m_full_2, DE_excl2_m_full_2,
                                     std.est ="std",
                                     title = "Germany", 
                                     axis.title = "Support",
                                     axis.labels = c("Sex: male", "Age", "Income", "Education: high", "Education: middle",
                                                     "Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                     "Authoritarian", "Strong reciprocity", 
                                                     "TAN-GAL", "Left-Right", "Neither European nor national identity", "Exclusive national identity", "Affectedness"),
                                     m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                     vline.color = "black",
                                     dot.size = 2,
                                     colors = "Set2")


##Italy
IT_OV3_m_full_1 <- lm(OV3 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                        edu + income + age + sex, data = IT)
IT_OV3_m_full_2 <- lm(OV3 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                        edu + income + age + sex, data = IT)
IT_cohe_m_full_1 <- lm(Exclusion_1 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                         edu + income + age + sex, data = IT)
IT_cohe_m_full_2 <- lm(Exclusion_1 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                         edu + income + age + sex, data = IT)
IT_excl2_m_full_1 <- lm(Exclusion_2_2 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                          edu + income + age + sex, data = IT)
IT_excl2_m_full_2 <- lm(Exclusion_2_2 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                          edu + income + age + sex, data = IT)

IT_exclusion_models_1 <- plot_models(IT_OV3_m_full_1, IT_cohe_m_full_1, IT_excl2_m_full_1,
                                     std.est ="std", 
                                     title = "Italy", 
                                     axis.title = "Support",
                                     axis.labels = c("Sex: male", "Age", "Income", "Education: high", "Education: middle", 
                                                     "Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                     "Authoritarian", "Strong reciprocity", 
                                                     "TAN-GAL", "Left-Right", "EU membership: neither good nor bad", "EU membership: good", "Affectedness"),                                    m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                     vline.color = "black",
                                     colors = "Set2")

IT_exclusion_models_2 <- plot_models(IT_OV3_m_full_2, IT_cohe_m_full_2, IT_excl2_m_full_2,
                                     std.est ="std",
                                     title = "Italy", 
                                     axis.title = "Support",
                                     axis.labels = c("Sex: male", "Age", "Income", "Education: high", "Education: middle",
                                                     "Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                     "Authoritarian", "Strong reciprocity", 
                                                     "TAN-GAL", "Left-Right", "Neither European nor national identity", "Exclusive national identity", "Affectedness"),
                                     m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                     vline.color = "black",
                                     dot.size = 2,
                                     colors = "Set2")


##Poland
PL_OV3_m_full_1 <- lm(OV3 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                        edu + income + age + sex, data = PL)
PL_OV3_m_full_2 <- lm(OV3 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                        edu + income + age + sex, data = PL)
PL_cohe_m_full_1 <- lm(Exclusion_1 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                         edu + income + age + sex, data = PL)
PL_cohe_m_full_2 <- lm(Exclusion_1 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                         edu + income + age + sex, data = PL)
PL_excl2_m_full_1 <- lm(Exclusion_2_2 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                          edu + income + age + sex, data = PL)
PL_excl2_m_full_2 <- lm(Exclusion_2_2 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                          edu + income + age + sex, data = PL)

PL_exclusion_models_1 <- plot_models(PL_OV3_m_full_1, PL_cohe_m_full_1, PL_excl2_m_full_1,
                                     std.est ="std", 
                                     title = "Poland", 
                                     axis.title = "Support",
                                     axis.labels = c("Sex: male", "Age", "Income", "Education: high", "Education: middle", 
                                                     "Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                     "Authoritarian", "Strong reciprocity", 
                                                     "TAN-GAL", "Left-Right", "EU membership: neither good nor bad", "EU membership: good", "Affectedness"),
                                     m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                     vline.color = "black",
                                     colors = "Set2")

PL_exclusion_models_2 <- plot_models(PL_OV3_m_full_2, PL_cohe_m_full_2, PL_excl2_m_full_2,
                                     std.est ="std",
                                     title = "Poland", 
                                     axis.title = "Support",
                                     axis.labels = c("Sex: male", "Age", "Income", "Education: high", "Education: middle",
                                                     "Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                     "Authoritarian", "Strong reciprocity", 
                                                     "TAN-GAL", "Left-Right", "Neither European nor national identity", "Exclusive national identity", "Affectedness"),
                                     m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                     vline.color = "black",
                                     dot.size = 2,
                                     colors = "Set2")

##Sweden
SWE_OV3_m_full_1 <- lm(OV3 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                         edu + income + age + sex, data = SWE)
SWE_OV3_m_full_2 <- lm(OV3 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                         edu + income + age + sex, data = SWE)
SWE_cohe_m_full_1 <- lm(Exclusion_1 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                          edu + income + age + sex, data = SWE)
SWE_cohe_m_full_2 <- lm(Exclusion_1 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                          edu + income + age + sex, data = SWE)
SWE_excl2_m_full_1 <- lm(Exclusion_2_2 ~ affectedness + membership + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                           edu + income + age + sex, data = SWE)

SWE_excl2_m_full_2 <- lm(Exclusion_2_2 ~ affectedness + nat_identity + leftright + GAL + strong_reciprocity + authoritarian + Q20 + Q18 + trust_nat + 
                           edu + income + age + sex, data = SWE)

SWE_exclusion_models_1 <- plot_models(SWE_OV3_m_full_1, SWE_cohe_m_full_1, SWE_excl2_m_full_1,
                                      std.est ="std", 
                                      title = "Sweden", 
                                      axis.title = "Support",
                                      axis.labels = c("Sex: male", "Age", "Income", "Education: high", "Education: middle", 
                                                      "Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                      "Authoritarian", "Strong reciprocity", 
                                                      "TAN-GAL", "Left-Right", "EU membership: neither good nor bad", "EU membership: good", "Affectedness"),
                                      m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                      vline.color = "black",
                                      colors = "Set2")

SWE_exclusion_models_2 <- plot_models(SWE_OV3_m_full_2, SWE_cohe_m_full_2, SWE_excl2_m_full_2,
                                      std.est ="std",
                                      title = "Sweden", 
                                      axis.title = "Support",
                                      axis.labels = c("Sex: male", "Age", "Income", "Education: high", "Education: middle",
                                                      "Political trust (national)", "Satisfaction with national democracy", "Judicial oversight", 
                                                      "Authoritarian", "Strong reciprocity", 
                                                      "TAN-GAL", "Left-Right", "Neither European nor national identity", "Exclusive national identity", "Affectedness"),
                                      m.labels = c("EU should take measures", "Exclusion from cohesion fund", "Exclusion from green subsidies"),
                                      vline.color = "black",
                                      dot.size = 2,
                                      colors = "Set2")

##Figure A4.1. Public support for EU measures against democratic backsliding. Country results. Standardised coefficients.
DE_exclusion_models_2 + IT_exclusion_models_2 + PL_exclusion_models_2 + SWE_exclusion_models_2 + 
  plot_layout(ncol = 2, guides = 'collect', axes = "collect") +
  plot_annotation(title = "Public support for EU measures against democratic backsliding")

##Figure A4.2. Public support for EU measures against democratic backsliding. Country results. Standardised coefficients.
DE_exclusion_models_1 + IT_exclusion_models_1 + PL_exclusion_models_1 + SWE_exclusion_models_1 + 
  plot_layout(ncol = 2, guides = 'collect', axes = "collect") + 
  plot_annotation(title = "Public support for EU measures against democratic backsliding")


##A5: Attitudes towards green subsidies

##Table A5. Public support for EU measures against democratic backsliding.
stargazer(greensub_m_full_2b, excl2_m_full_2b, excl2_int1_full, excl2_int3_full,
          type = "html",
          out = "green_subsidies_int1.html", 
          title = "Public Attitudes towards Green Subsidies",
          dep.var.labels = c("Support for green subsidies", "Exclusion from green subsidies", "Exclusion from green subsidies"),
          covariate.labels = c("Climate change worry", "Affectedness", "Exclusive national identity", "Neither European nor national identity",
                               "Left-Right", "TAN-GAL", 
                               "Strong reciprocity", "Authoritarian","Judicial oversight", 
                               "Satisfaction with national democracy", "Political trust (national)", 
                               "Education: middle", "Education: high", "Income", "Age", "Male", 
                               "Treatment group: T1", "Treatment group: T2", "Treatment group: T3", 
                               "EU should take action", "EU should take action X Climate change worry", 
                               "Support for green subsidies", "EU should take action X Support for green subsidies"),
          model.numbers    = TRUE,
          star.cutoffs = c(0.05, 0.01, 0.001))


##A6: Experimental results: Pooled sample

##Table A6.1. Experimental Treatments and Regime Support
stargazer(m1, m2, m4a, m4b,  
          type= "html",
          out = "experiment_regime_support_2024.03.28.html", 
          title            = "Experimental Treatment and Regime Support",
          dep.var.labels   = c("EU Satisfaction", "EU Unification", "COM Trust", "EP Trust"),
          model.numbers    = FALSE,
          star.cutoffs = c(0.05, 0.01, 0.001))

##Table A6.2. Experimental Treatments and Regime Support (with Control Variables)
OV1_m_full <- lm(OV1 ~ tgroup + affectedness + nat_identity + leftright + GAL + edu + income + age + sex, data = data_eu)
OV2_m_full <- lm(OV2 ~ tgroup + affectedness + nat_identity + leftright + GAL + edu + income + age + sex, data = data_eu)
OV4r1_m_full <- lm(OV4r1 ~ tgroup + affectedness + nat_identity + leftright + GAL + edu + income + age + sex, data = data_eu)
OV4r2_m_full <- lm(OV4r2 ~ tgroup + affectedness + nat_identity + leftright + GAL + edu + income + age + sex, data = data_eu)

stargazer(OV1_m_full, OV2_m_full, OV4r1_m_full, OV4r2_m_full,  
          type= "html",
          out = "experiment_regime_support_controls_2024.03.28.html", 
          title            = "Experimental Treatment and Regime Support",
          dep.var.labels   = c("EU Satisfaction", "EU Unification", "COM Trust", "EP Trust"),
          model.numbers    = FALSE,
          star.cutoffs = c(0.05, 0.01, 0.001))

##Table A6.3. Experimental Treatments and Policy Support 
stargazer(m3, m5, m6,
          type= "html",
          out = "experiment_policy_support_2024.03.28.html", 
          title            = "Experimental Treatment and EU Policy Support",
          dep.var.labels   = c("EU measures","Police and Judicial Cooperation", "Green Investment Fund"),
          model.numbers    = FALSE,
          star.cutoffs = c(0.05, 0.01, 0.001))

##Table A6.4. Experimental Treatments and Policy Support (with Control Variables)
OV3_m_full <- lm(OV3 ~ tgroup + affectedness + nat_identity + leftright + GAL + edu + income + age + sex, data = data_eu)
OV5_m_full <- lm(OV5 ~ tgroup + nat_identity + leftright + GAL + edu + income + age + sex, data = data_eu)
OV6_m_full <- lm(OV6 ~ tgroup + nat_identity + leftright + GAL + edu + income + age + sex, data = data_eu)

stargazer(OV3_m_full, OV5_m_full, OV6_m_full,
          type= "html",
          out = "experiment_policy_support_controls_2024.03.28.html", 
          title            = "Experimental Treatment and EU Policy Support",
          dep.var.labels   = c("EU measures","Police and Judicial Cooperation", "Green Investment Fund"),
          model.numbers    = FALSE,
          star.cutoffs = c(0.05, 0.01, 0.001))


#A7: Experimental results: subgroup analyses

data_eu <- data_eu %>% mutate(nat_identity = as.factor(nat_identity))
data_eu <- data_eu %>% mutate(edu = as.factor(edu))

##OV1 = EU functioning
OV1_ident <- lm(OV1 ~ tgroup*nat_identity, data = data_eu)
OV1_gal <- lm(OV1 ~ tgroup*GAL, data = data_eu)
OV1_reciprocity <- lm(OV1 ~ tgroup*strong_reciprocity, data = data_eu)
OV1_knowledge <- lm(OV1 ~ tgroup* knowledge, data = data_eu)
OV1_edu <- lm(OV1 ~ tgroup* edu, data = data_eu)
OV1_sanct <- lm(OV1 ~ tgroup* as.numeric(OV3), data = data_eu)

##OV2 = Integration should go further
OV2_ident <- lm(OV2 ~ tgroup*nat_identity, data = data_eu)
OV2_gal <- lm(OV1 ~ tgroup*GAL, data = data_eu)
OV2_reciprocity <- lm(OV2 ~ tgroup*strong_reciprocity, data = data_eu)
OV2_knowledge <- lm(OV2 ~ tgroup* knowledge, data = data_eu)
OV2_edu <- lm(OV2 ~ tgroup* edu, data = data_eu)
OV2_sanct <- lm(OV2 ~ tgroup* as.numeric(OV3), data = data_eu)

##OV3 = EU should take actions to protect RoL
OV3_ident <- lm(OV3 ~ tgroup*nat_identity, data = data_eu)
OV3_gal <- lm(OV3 ~ tgroup*GAL, data = data_eu)
OV3_reciprocity <- lm(OV3 ~ tgroup*strong_reciprocity, data = data_eu)
OV3_knowledge <- lm(OV3 ~ tgroup* knowledge, data = data_eu)
OV3_edu <- lm(OV3 ~ tgroup* edu, data = data_eu)

##OV4r1 = COM trust
OV4r1_ident <- lm(OV4r1 ~ tgroup*nat_identity, data = data_eu)
OV4r1_gal <- lm(OV4r1 ~ tgroup*GAL, data = data_eu)
OV4r1_reciprocity <- lm(OV4r1 ~ tgroup*strong_reciprocity, data = data_eu)
OV4r1_knowledge <- lm(OV4r1 ~ tgroup* knowledge, data = data_eu)
OV4r1_edu <- lm(OV4r1 ~ tgroup* edu, data = data_eu)
OV4r1_sanct <- lm(OV4r1 ~ tgroup* as.numeric(OV3), data = data_eu)

##OV4r2 = EP trust
OV4r2_ident <- lm(OV4r2 ~ tgroup*nat_identity, data = data_eu)
OV4r2_gal <- lm(OV4r2 ~ tgroup*GAL, data = data_eu)
OV4r2_reciprocity <- lm(OV4r2 ~ tgroup*strong_reciprocity, data = data_eu)
OV4r2_knowledge <- lm(OV4r2 ~ tgroup* knowledge, data = data_eu)
OV4r2_edu <- lm(OV4r2 ~ tgroup* edu, data = data_eu)
OV4r2_sanct <- lm(OV4r2 ~ tgroup* as.numeric(OV3), data = data_eu)

##OV5 = police cooperation
OV5_ident <- lm(OV5 ~ tgroup*nat_identity, data = data_eu)
OV5_gal <- lm(OV5 ~ tgroup*GAL, data = data_eu)
OV5_reciprocity <- lm(OV5 ~ tgroup*strong_reciprocity, data = data_eu)
OV5_knowledge <- lm(OV5 ~ tgroup* knowledge, data = data_eu)
OV5_edu <- lm(OV5 ~ tgroup* edu, data = data_eu)
OV5_sanct <- lm(OV5 ~ tgroup* as.numeric(OV3), data = data_eu)

##OV6 = green investment fund
OV6_ident <- lm(OV6 ~ tgroup*nat_identity, data = data_eu)
OV6_gal <- lm(OV6 ~ tgroup*GAL, data = data_eu)
OV6_reciprocity <- lm(OV6 ~ tgroup*strong_reciprocity, data = data_eu)
OV6_knowledge <- lm(OV6 ~ tgroup* knowledge, data = data_eu)
OV6_edu <- lm(OV6 ~ tgroup* edu, data = data_eu)
OV6_sanct <- lm(OV6 ~ tgroup* as.numeric(OV3), data = data_eu)


##Figure A7.1 Heterogeneous treatment effects: Strong reciprocity
reciprocity_ov1   <- plot_model(OV1_reciprocity,   type = "int", terms = c("strong_reciprocity","tgroup"), title = "EU Functioning",                    legend.title = "Strong reciprocity", axis.title = "Satisfaction")
reciprocity_ov2   <- plot_model(OV2_reciprocity,   type = "int", terms = c("strong_reciprocity","tgroup"), title = "EU Unification",                    legend.title = "Strong reciprocity", axis.title = "unification should go further")
reciprocity_ov3   <- plot_model(OV3_reciprocity,   type = "int", terms = c("strong_reciprocity","tgroup"), title = "EU Actions",                        legend.title = "Strong reciprocity", axis.title = "EU should take actions")
reciprocity_ov4r1 <- plot_model(OV4r1_reciprocity, type = "int", terms = c("strong_reciprocity","tgroup"), title = "Trust in COM",                      legend.title = "Strong reciprocity", axis.title = "Trust in COM")
reciprocity_ov4r2 <- plot_model(OV4r2_reciprocity, type = "int", terms = c("strong_reciprocity","tgroup"), title = "Trust in EP",                       legend.title = "Strong reciprocity", axis.title = "Trust in EP")
reciprocity_ov5   <- plot_model(OV5_reciprocity,   type = "int", terms = c("strong_reciprocity","tgroup"), title = "Support for Police Cooperation",    legend.title = "Strong reciprocity", axis.title = "Support for police cooperation")
reciprocity_ov6   <- plot_model(OV6_reciprocity,   type = "int", terms = c("strong_reciprocity","tgroup"), title = "Support for Green Investment Fund", legend.title = "Strong reciprocity", axis.title = "Support for green investment fund")

reciprocity_ov1 + reciprocity_ov2 + reciprocity_ov3 + reciprocity_ov4r1 + reciprocity_ov5 + reciprocity_ov6 +
  plot_layout(ncol = 2, guides = "collect") +
  plot_annotation(title = "Heterogeneous treatment effects: Strong Reciprocity", tag_levels = "I")

##Figure A7.2 Heterogeneous treatment effects: Identity
identity_ov1   <- plot_model(OV1_ident,   type = "int", title = "EU Functioning",                    legend.title = "Identity", axis.title = "Satisfaction ")
identity_ov2   <- plot_model(OV2_ident,   type = "int", title = "EU Unification",                    legend.title = "Identity", axis.title = "Unification should go further")
identity_ov3   <- plot_model(OV3_ident,   type = "int", title = "EU Actions",                        legend.title = "Identity", axis.title = "EU should take action")
identity_ov4r1 <- plot_model(OV4r1_ident, type = "int", title = "Trust in COM",                      legend.title = "Identity", axis.title = "Trust in COM")
identity_ov4r2 <- plot_model(OV4r2_ident, type = "int", title = "Trust in EP",                       legend.title = "Identity", axis.title = "Trust in EP")
identity_ov5   <- plot_model(OV5_ident,   type = "int", title = "Support for Police Cooperation",    legend.title = "Identity", axis.title = "Support for police cooperation")
identity_ov6   <- plot_model(OV6_ident,   type = "int", title = "Support for Green Investment Fund", legend.title = "Identity", axis.title = "Support for green investment fund")

identity_ov1 + identity_ov2 + identity_ov3 + identity_ov4r1 + identity_ov5 + identity_ov6 +
  plot_layout(ncol = 2, guides = "collect") +
  plot_annotation(title = "Heterogeneous treatment effects: Identity", tag_levels = "I")

##Figure A7.3 Heterogeneous treatment effects: GAL/TAN
gal_ov1   <- plot_model(OV1_gal,   type = "pred", terms = c("GAL","tgroup"), title = "EU Functioning",                    legend.title = "Treatment group", axis.title = "Satisfaction")
gal_ov2   <- plot_model(OV2_gal,   type = "pred", terms = c("GAL","tgroup"), title = "EU Unification",                    legend.title = "Treatment group", axis.title = "Unification should go further")
gal_ov3   <- plot_model(OV3_gal,   type = "pred", terms = c("GAL","tgroup"), title = "EU Actions",                        legend.title = "Treatment group", axis.title = "EU should take action")
gal_ov4r1 <- plot_model(OV4r1_gal, type = "pred", terms = c("GAL","tgroup"), title = "Trust in COM",                      legend.title = "Treatment group", axis.title = "Trust in COM")
gal_ov4r2 <- plot_model(OV4r2_gal, type = "pred", terms = c("GAL","tgroup"), title = "Trust in EP",                       legend.title = "Treatment group", axis.title = "Trust in EP")
gal_ov5   <- plot_model(OV5_gal,   type = "pred", terms = c("GAL","tgroup"), title = "Support for Police Cooperation",    legend.title = "Treatment group", axis.title = "Support for police cooperation")
gal_ov6   <- plot_model(OV6_gal,   type = "pred", terms = c("GAL","tgroup"), title = "Support for Green Investment Fund", legend.title = "Treatment group", axis.title = "Support for green investment fund")

gal_ov1 + gal_ov2 + gal_ov3 + gal_ov4r1 + gal_ov5 + gal_ov6 +
  plot_layout(ncol = 2, guides = "collect") +
  plot_annotation(title = "Heterogeneous treatment effects: GAL/TAN", tag_levels = "I")

##Figure A7.4 Heterogeneous treatment effects: Education
education_ov1   <- plot_model(OV1_edu,   type = "int", title = "EU Functioning",                    legend.title = "Education", axis.title = "Satisfaction ")
education_ov2   <- plot_model(OV2_edu,   type = "int", title = "EU Unification",                    legend.title = "Education", axis.title = "Unification should go further")
education_ov3   <- plot_model(OV3_edu,   type = "int", title = "EU Actions",                        legend.title = "Education", axis.title = "EU should take action")
education_ov4r1 <- plot_model(OV4r1_edu, type = "int", title = "Trust in COM",                      legend.title = "Education", axis.title = "Trust in COM")
education_ov4r2 <- plot_model(OV4r2_edu, type = "int", title = "Trust in EP",                       legend.title = "Education", axis.title = "Trust in EP")
education_ov5   <- plot_model(OV5_edu,   type = "int", title = "Support for Police Cooperation",    legend.title = "Education", axis.title = "Support for police cooperation")
education_ov6   <- plot_model(OV6_edu,   type = "int", title = "Support for Green Investment Fund", legend.title = "Education", axis.title = "Support for green investment fund")

education_ov1 + education_ov2 + education_ov4r1 + education_ov4r2 + education_ov5 + education_ov6 +
  plot_layout(ncol = 2, guides = "collect") +
  plot_annotation(title = "Heterogeneous treatment effects: Education", tag_levels = "I")

##Figure A7.5 Heterogeneous treatment effects: Political knowledge
knowledge_ov1   <- plot_model(OV1_knowledge,   type = "pred", terms = c("knowledge", "tgroup"), title = "EU Functioning",                    legend.title = "Treatment group", axis.title = "Satisfaction with EU functioning")
knowledge_ov2   <- plot_model(OV2_knowledge,   type = "pred", terms = c("knowledge", "tgroup"), title = "EU Unification",                    legend.title = "Treatment group", axis.title = "EU unification should go further")
knowledge_ov3   <- plot_model(OV3_knowledge,   type = "pred", terms = c("knowledge", "tgroup"), title = "EU Actions",                        legend.title = "Treatment group", axis.title = "EU should take action against RoL violations")
knowledge_ov4r1 <- plot_model(OV4r1_knowledge, type = "pred", terms = c("knowledge", "tgroup"), title = "Trust in COM",                      legend.title = "Treatment group", axis.title = "Trust in COM")
knowledge_ov4r2 <- plot_model(OV4r2_knowledge, type = "pred", terms = c("knowledge", "tgroup"), title = "Trust in EP",                       legend.title = "Treatment group", axis.title = "Trust in EP")
knowledge_ov5   <- plot_model(OV5_knowledge,   type = "pred", terms = c("knowledge", "tgroup"), title = "Support for Police Cooperation",    legend.title = "Treatment group", axis.title = "Support for police cooperation")
knowledge_ov6   <- plot_model(OV6_knowledge,   type = "pred", terms = c("knowledge", "tgroup"), title = "Support for Green Investment Fund", legend.title = "Treatment group", axis.title = "Support for green investment fund")

knowledge_ov1 + knowledge_ov2 + knowledge_ov3 + knowledge_ov4r1 + knowledge_ov5 + knowledge_ov6 +
  plot_layout(ncol = 2, guides = "collect") +
  plot_annotation(title = "Heterogeneous treatment effects: Political Knowledge", tag_levels = "I")

##Figure A7.6 Heterogeneous treatment effects: Opinion extremity in sanction preferences
sanction_ov1   <- plot_model(OV1_sanct,   type = "pred", terms = c("OV3", "tgroup"),  title = "EU Functioning",                    legend.title = "Treatment group", axis.title = c("Sanction preferences", "Satisfaction "))
sanction_ov2   <- plot_model(OV2_sanct,   type = "pred", terms = c("OV3", "tgroup"),  title = "EU Unification",                    legend.title = "Treatment group", axis.title = c("Sanction preferences", "Unification should go further"))
sanction_ov4r1 <- plot_model(OV4r1_sanct, type = "pred", terms = c("OV3", "tgroup"),  title = "Trust in COM",                      legend.title = "Treatment group", axis.title = c("Sanction preferences", "Trust in COM"))
sanction_ov4r2 <- plot_model(OV4r2_sanct, type = "pred", terms = c("OV3", "tgroup"),  title = "Trust in EP",                       legend.title = "Treatment group", axis.title = c("Sanction preferences", "Trust in EP"))
sanction_ov5   <- plot_model(OV5_sanct,   type = "pred", terms = c("OV3", "tgroup"),  title = "Support for Police Cooperation",    legend.title = "Treatment group", axis.title = c("Sanction preferences", "Support for police cooperation"))
sanction_ov6   <- plot_model(OV6_sanct,   type = "pred", terms = c("OV3", "tgroup"),  title = "Support for Green Investment Fund", legend.title = "Treatment group", axis.title = c("Sanction preferences", "Support for green investment fund"))

sanction_ov1 + sanction_ov2 + sanction_ov4r1 + sanction_ov4r2 + sanction_ov5 + sanction_ov6 +
  plot_layout(ncol = 2, guides = "collect") +
  plot_annotation(title = "Heterogeneous treatment effects: Sanction preferences", tag_levels = "I")


#A8: Experimental results: Country results

##Germany

DE_m1 = lm(OV1 ~ tgroup, data = DE)
DE_m2 = lm(OV2 ~ tgroup, data = DE)
DE_m4a = lm(OV4r1 ~ tgroup, data = DE)
DE_m4b = lm(OV4r2 ~ tgroup, data = DE)
DE_m5 = lm(OV5 ~ tgroup, data = DE)
DE_m6 = lm(OV6 ~ tgroup, data = DE)

DE_OV1_effect <- plot_model(DE_m1, type ="pred", 
                            title = "Satisfaction with EU functioning", 
                            axis.title = "Satisfaction")
DE_OV2_effect <- plot_model(DE_m2, type ="pred", 
                            title = "Unification should go further", 
                            axis.title = "Support")
DE_OV4r1_effect <- plot_model(DE_m4a, type ="pred",
                              title = "Trust in European Commission", 
                              axis.title = "Trust")
DE_OV4r2_effect <- plot_model(DE_m4b, type ="pred",
                              title = "Trust in European Parliament", 
                              axis.title = "Trust")
DE_OV5_effect <- plot_model(DE_m5, type ="pred", 
                            title = "Support for Police & Judicial Cooperation", 
                            axis.title = "Support")
DE_OV6_effect <- plot_model(DE_m6, type ="pred", 
                            title = "Support for Green Investment Fund", 
                            axis.title = "Support")

##Figure A8.1 Treatment effects in Germany
pred_grid_DE <- plot_grid(c(DE_OV1_effect, DE_OV2_effect, DE_OV4r1_effect, DE_OV4r2_effect, DE_OV5_effect, DE_OV6_effect))
ggsave("experiment_predicted_values_DE.png", pred_grid, dpi = 600)

 ##Table A8.1 Treatment effects in Germany
stargazer(DE_m1, DE_m2, DE_m4a, DE_m4b, DE_m5, DE_m6,   
          type= "html",
          out = "de_experiment_regime_support.html", 
          title            = "Experimental Treatment and EU Support: Germany",
          dep.var.labels   = c("EU Satisfaction", "EU Unification", "COM Trust", "EP Trust",
                               "Police and Judicial Cooperation", "Green Investment Fund"),
          model.numbers    = FALSE,
          star.cutoffs = c(0.05, 0.01, 0.001))


##Italy

IT_m1 = lm(OV1 ~ tgroup, data = IT)
IT_m2 = lm(OV2 ~ tgroup, data = IT)
IT_m4a = lm(OV4r1 ~ tgroup, data = IT)
IT_m4b = lm(OV4r2 ~ tgroup, data = IT)
IT_m5 = lm(OV5 ~ tgroup, data = IT)
IT_m6 = lm(OV6 ~ tgroup, data = IT)

IT_OV1_effect <- plot_model(IT_m1, type ="pred", 
                            title = "Satisfaction with EU functioning", 
                            axis.title = "Satisfaction")
IT_OV2_effect <- plot_model(IT_m2, type ="pred", 
                            title = "Unification should go further", 
                            axis.title = "Support")
IT_OV4r1_effect <- plot_model(IT_m4a, type ="pred",
                              title = "Trust in European Commission", 
                              axis.title = "Trust")
IT_OV4r2_effect <- plot_model(IT_m4b, type ="pred",
                              title = "Trust in European Parliament", 
                              axis.title = "Trust")
IT_OV5_effect <- plot_model(IT_m5, type ="pred", 
                            title = "Support for Police & Judicial Cooperation", 
                            axis.title = "Support")
IT_OV6_effect <- plot_model(IT_m6, type ="pred", 
                            title = "Support for Green Investment Fund", 
                            axis.title = "Support")

##Figure A8.2 Treatment effects in Italy
pred_grid_IT <- plot_grid(c(IT_OV1_effect, IT_OV2_effect, IT_OV4r1_effect, IT_OV4r2_effect, IT_OV5_effect, IT_OV6_effect))
ggsave("experiment_predicted_values_IT.png", pred_grid, dpi = 600)

##Table A8.2 Treatment effects in Italy
stargazer(IT_m1, IT_m2, IT_m4a, IT_m4b, IT_m5, IT_m6,   
          type= "html",
          out = "it_experiment_regime_support.html", 
          title            = "Experimental Treatment and EU Support: Italy",
          dep.var.labels   = c("EU Satisfaction", "EU Unification", "COM Trust", "EP Trust",
                               "Police and Judicial Cooperation", "Green Investment Fund"),
          model.numbers    = FALSE,
          star.cutoffs = c(0.05, 0.01, 0.001))


##Poland

PL_m1 = lm(OV1 ~ tgroup, data = PL)
PL_m2 = lm(OV2 ~ tgroup, data = PL)
PL_m4a = lm(OV4r1 ~ tgroup, data = PL)
PL_m4b = lm(OV4r2 ~ tgroup, data = PL)
PL_m5 = lm(OV5 ~ tgroup, data = PL)
PL_m6 = lm(OV6 ~ tgroup, data = PL)

PL_OV1_effect <- plot_model(PL_m1, type ="pred", 
                            title = "Satisfaction with EU functioning", 
                            axis.title = "Satisfaction")
PL_OV2_effect <- plot_model(PL_m2, type ="pred", 
                            title = "Unification should go further", 
                            axis.title = "Support")
PL_OV4r1_effect <- plot_model(PL_m4a, type ="pred",
                              title = "Trust in European Commission", 
                              axis.title = "Trust")
PL_OV4r2_effect <- plot_model(PL_m4b, type ="pred",
                              title = "Trust in European Parliament", 
                              axis.title = "Trust")
PL_OV5_effect <- plot_model(PL_m5, type ="pred", 
                            title = "Support for Police & Judicial Cooperation", 
                            axis.title = "Support")
PL_OV6_effect <- plot_model(PL_m6, type ="pred", 
                            title = "Support for Green Investment Fund", 
                            axis.title = "Support")

##Figure A8.3 Treatment effects in Poland
pred_grid_PL <- plot_grid(c(PL_OV1_effect, PL_OV2_effect, PL_OV4r1_effect, PL_OV4r2_effect, PL_OV5_effect, PL_OV6_effect))
ggsave("experiment_predicted_values_PL.png", pred_grid, dpi = 600)

##Table A8.3 Treatment effects in Poland
stargazer(PL_m1, PL_m2, PL_m4a, PL_m4b, PL_m5, PL_m6,   
          type= "html",
          out = "pl_experiment_regime_support.html", 
          title            = "Experimental Treatment and EU Support: Poland",
          dep.var.labels   = c("EU Satisfaction", "EU Unification", "COM Trust", "EP Trust",
                               "Police and Judicial Cooperation", "Green Investment Fund"),
          model.numbers    = FALSE,
          star.cutoffs = c(0.05, 0.01, 0.001))


##Sweden

SWE_m1 = lm(OV1 ~ tgroup, data = SWE)
SWE_m2 = lm(OV2 ~ tgroup, data = SWE)
SWE_m4a = lm(OV4r1 ~ tgroup, data = SWE)
SWE_m4b = lm(OV4r2 ~ tgroup, data = SWE)
SWE_m5 = lm(OV5 ~ tgroup, data = SWE)
SWE_m6 = lm(OV6 ~ tgroup, data = SWE)

SWE_OV1_effect <- plot_model(SWE_m1, type ="pred", 
                             title = "Satisfaction with EU functioning", 
                             axis.title = "Satisfaction")
SWE_OV2_effect <- plot_model(SWE_m2, type ="pred", 
                             title = "Unification should go further", 
                             axis.title = "Support")
SWE_OV4r1_effect <- plot_model(SWE_m4a, type ="pred",
                               title = "Trust in European Commission", 
                               axis.title = "Trust")
SWE_OV4r2_effect <- plot_model(SWE_m4b, type ="pred",
                               title = "Trust in European Parliament", 
                               axis.title = "Trust")
SWE_OV5_effect <- plot_model(SWE_m5, type ="pred", 
                             title = "Support for Police & Judicial Cooperation", 
                             axis.title = "Support")
SWE_OV6_effect <- plot_model(SWE_m6, type ="pred", 
                             title = "Support for Green Investment Fund", 
                             axis.title = "Support")

##Figure A8.4 Treatment effects in Sweden
pred_grid_SWE <- plot_grid(c(SWE_OV1_effect, SWE_OV2_effect, SWE_OV4r1_effect, SWE_OV4r2_effect, SWE_OV5_effect, SWE_OV6_effect))
ggsave("experiment_predicted_values_SWE.png", pred_grid_SWE, dpi = 600)

##Table A8.4 Treatment effects in Sweden
stargazer(SWE_m1, SWE_m2, SWE_m4a, SWE_m4b, SWE_m5, SWE_m6,   
          type= "html",
          out = "swe_experiment_regime_support.html", 
          title            = "Experimental Treatment and EU Support: Sweden",
          dep.var.labels   = c("EU Satisfaction", "EU Unification", "COM Trust", "EP Trust",
                               "Police and Judicial Cooperation", "Green Investment Fund"),
          model.numbers    = FALSE,
          star.cutoffs = c(0.05, 0.01, 0.001))